package com.gxy.learn.design.model.construction.flyweight;

import java.util.HashMap;
import java.util.Map;

/**
 * @description: 单例工厂 饿汉式
 * @author: gaoxueyong
 * @Date: 2022/11/8 10:30
 */
public class BoxFactory {

    private Map<String, AbstractBox> map;

    private BoxFactory() {
        map = new HashMap<>();
        map.put("I", new IBox());
        map.put("L", new LBox());
        map.put("O", new OBox());
    }

    private static BoxFactory factory = new BoxFactory();

    public static BoxFactory getInstance() {
        return factory;
    }

    public AbstractBox getShape(String type) {
        return map.get(type);
    }
}
